package com.zhongshengnetwork.rightbe.common.Filter;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;

public class FilterTools {

    /**
     * 图片特效处理
     * @param bmp  传入的图片
     * @return
     */
    public static Bitmap toProcessImage(Bitmap bmp, int index){
        if(bmp!=null && index > 0 && index <= 13){
            index -= 1;
            int width, height;
            height = bmp.getHeight();
            width = bmp.getWidth();
            Bitmap bm = Bitmap.createBitmap(width, height,
                    Bitmap.Config.RGB_565);
            Paint myPaint = new Paint();
            Canvas canvas=new Canvas(bm);
            ColorMatrix myColorMatrix = new ColorMatrix();
            myColorMatrix.set(FilterColorMatrix.getColorMatrix(index));
            myPaint.setColorFilter(new ColorMatrixColorFilter(myColorMatrix));
            canvas.drawBitmap(bmp,0,0,myPaint);
            return bm;
        }else{
            return bmp;
        }

    }

}
